home *** CD-ROM | disk | FTP | other *** search
- Java on Linux HOWTO
- maintained by Eric S. Raymond, <esr@snark.thyrsus.com>
- v1.0, 10 December 1995
-
- This document describes how to get started with Java and HotJava under
- Linux, as either a user or a programmer.
-
- 1. Introduction
-
- This document is a Linux-centric introduction to the world of Java and
- HotJava. These technologies are rapidly evolving, and we welcome
- contributions from anywhere.
-
- Places in this document that are in serious need of checking or
- filling out are bracketed with *** ***. Also see the ``To Be
- Added...'' section below. Please help us improve this HOWTO.
-
- 2. General Questions About Java and HotJava
-
- This section is a general (non-Linux-specific) introduction to Java
- and HotJava.
-
-
- 2.1. What are are Java and HotJava and why are they interesting?
-
- Java is a network-aware language superficially resembling C++, but
- much smaller and more compact and cleanly designed. It's an
- unlimited-extent language with garbage collection like Lisp, but with
- strong type checking. It includes lightweight processes (threads) as
- a native facility and has powerful network-security features. So far,
- its major application is the HotJava browser, but it holds
- considerable promise as a general-purpose application language.
-
- HotJava is a WWW browser written in Java. Its major advance over
- other browsers is that it knows about a new HTML construct called an
- APP, which is some Java class that executes on the client machine.
- Thus, WWW documents written with Java in mind can have "live" code
- objects embedded in them, as opposed to just data.
-
- The ability to safely pass around code objects probably represents the
- most significant advance in WWW technology since the first release of
- Mosaic. At minimum, it delivers an extensible Web browser that won't
- need perpetual upgrading to handle new image formats and tag types.
-
- 2.2. Where do Java and HotJava come from? Who can use them?
-
- Java and HotJava were developed at Sun Microsystems by a team headed
- by James Gosling (well known as the designer of Gosling Emacs and
- NeWS).
-
- The last time Sun tried to set a major technical standard was NeWS,
- its Network Window System. Though NeWS was pretty universally
- conceded to be technically superior to X, X won because its sources
- were freely redistributable. Sun learned from this mistake, and has
- made Java/HotJava much more generally available; the sources can be
- downloaded under a fairly relaxed license (see ``Java as Freely
- Redistributable Software''). Sun is encouraging ports to non-Sun
- environments.
-
- Netscape now interprets Java. Microsoft licensed the technology in
- early December 1995. So it appears that Java support will probably
- become universal in 1996.
-
- Java used to be called Oak. HotJava was once known as WebRunner.
-
-
- 2.3. How mature is Java?
-
- Java is currently (December 1995) in late beta at Sun. The Java
- environment API defining its access to the host OS and windowing
- system has allegedly been semi-frozen -- it may be extended, but won't
- be incompatibly changed.
-
- The 1.0 version of this FAQ is being issued along with the beta 1.0
- Java Developer's Kit (JDK) for Linux, ported by Randy Chapman.
-
- Significant holes are known to exist in the Java security
- implementation. It is not yet a good idea to use Java for sensitive
- applications. These problems are expected to be fixed in the
- production (post-beta) releases.
-
- 2.4. Where can I find documentation on Java and HotJava?
-
- Sun maintains an extensive HTML web of Java and HotJava-related
- documents at <http://java.sun.com>. These documents are mirrored at
- <http://java.blackdown.com> and elsewhere; see Sun's list of mirror
- sites.
-
- 2.5. Yes, but where can I find paper documentation?
-
- SunSoft Press's official series of Java books is in the production
- pipeline at Addison-Wesley. Some details about these can be found in
- the comp.lang.java FAQ <http://www.city-net.com/~krom/java-faq.html>.
-
- O'Reilly Associates is working on its own series of Java books in
- cooperation with Sun. These are expected to include (at least) a
- "Nutshell Guide To Java", a language reference, a class library
- reference, and a book on the underlying byte-code virtual machine.
- (Full-disclosure statement: Your HOWTO editor has been invited by
- O'Reilly Associates to serve as primary technical reviewer for this
- series, and will be paid for that work.)
-
- Per information on Sun's java web pages, SAMS will be publishing in
- December, 1995, "Learing Java in 21 Days". I checked with the local
- (Vienna, VA) Computer Learning Center bookstore; they expect to
- receive their first shipment sometime in mid-late December.
-
- One of our contributors, browsing his local Bookstop/Barnes &
- Noble/Borders, came up with 3 books already out:
-
- o One called 'Java in 60 minutes' that looked like a pretty strict
- syntactic description (about $20).
-
- o One from SamsNet called just `Java' (about $20).
-
- o One by Tim Ritchey called `Java!' that includes a CD-ROM (about
- $35).
-
- Our informant continues: "I bought the 3rd one (by Tim Ritchey).
- Paper leadtimes being what they are, the CD-ROM only has alpha
- stuff, though it mentions that the beta version might be out by the
- time you read it and suggests java.sun.com as a place to get more
- recent information. Other than that, it's pretty good, even to
- pointing out that `well, it's pointless for me to spam you with
- pages and pages of API descriptions because 1) it would quadruple
- the size of the book and 20 they're still ch anging and 2) you can
- get that info online at ...etc'"
-
- 2.6. Where can I find on-line collections of Java code?
-
- WWW archives of applets are available at the following locations:
-
- o <http://java.sun.com/>
-
- o <http://www.applets.com/>
-
- o <http://www.gamelan.com/>
-
- o <http://www.javasoft.com/applets/applets.html>
-
- Most of the applets on these pages come with source code, and
- programmers are invited to use them.
-
- Pointers to others may be available in the comp.lang.java FAQ
- <http://www.city-net.com/~krom/java-faq.html>.
-
- 3. Java as Freely Redistributable Software
-
- Many Linux programmers are attached to producing freely
- redistributable software (FRS), and try to avoid committing a lot of
- time to tools for which sources are not generally available. In this
- section, we discuss Sun's and Java's relationship with the FRS world.
-
- (Warning: I am not a lawyer. I am neither employed by, nor an agent
- of, nor a stockholder in, Sun Microsystems. This section is based on
- my interpretation of the current copyright law and the Sun licensing
- language. Treat this as an introduction; the Sun licensing page,
- <http://www.blackdown.org/Java/licensing.html> is definitive. If you
- are in serious doubt about what it means, consult an attorney.)
-
-
- 3.1. Are Java programs and applets freely redistributable?
-
- They are if you write them and choose to make them FRS through some
- mechanism (such as the GPL, or a BSD-style license, or declaring them
- public domain).
-
-
- 3.2. What can I do with Java implementation binaries?
-
- The Sun licensing page has this to say:
-
- The unmodified Java and HotJava binary releases may be
- redistributed free of charge in both commercial and non-
- commercial applications.
-
-
- Also:
-
- Companies or individuals who wish to create a new port of
- the Java language have the right under this agreement to
- post the binaries of that port to the Internet for use by
- others, as long as the port is free of charge and passes the
- publicly available test suites. (Test suites will be avail-
- able sometime in the first half of 1996.) The "diffs" may
- also be posted on the web as long as the underlying source
- code is not posted. The Java source code is
-
-
- So if you've got a working Java or HotJava binary, you can give it to
- your buddies. Or put it on a CD-ROM. Or do anything except patch it
- and represent the patched version as Java. (This is reasonable. Sun
- obviously can't leave itself without recourse against Trojan horses
- sailing under the Java banner.) Binaries are FRS.
-
-
-
-
- 3.3. Which parts of the Java sources are freely redistributable?
-
- According to Sun's licensing page, none of it is. But that sounds
- harsher than it is. In practice, anyone can get the Java and HotJava
- sources for educational, porting, and non-commercial purposes by
- filling out a Web form which obligates them not to redistribute the
- sources. And the agreement does permit redistribution of diffs
- against the sources.
-
- The only circumstance that requires you to sign a commercial license
- with Sun and pay them money is if you want to use the sources in a
- commercial product. In particular, the way the language is written,
- it's within the letter and spirit of the agreement for you to sign
- Sun's noncommercial source license, snarf the source, port it, and
- give away the results as completely unencumbered freeware!
-
- Sun says that its primary purpose in keeping as much control as it has
- is to keep the language from mutating into incompatible dialects. The
- license language supports this; it seems to have been designed to
- allow hackers to play for free.
-
- 3.4. Is anyone cloning Java in freely redistributable source?
-
- Not that we know of, yet. The Sun licensing page says:
-
- The specifications for the Java Language and the Java Vir-
- tual Machine are OPEN and are copyrighted by Sun Microsys-
- tems, Inc.
-
-
-
- Reimplementations of the Java Compiler or the Java Runtime
- Interpreter are permitted without requiring a license from
- Sun provided such implementations are created directly from
- the published specifications and without the direct or indi-
- rect use of Sun's own implementations or other intellectual
- property rights, including trademarks.
-
-
- So if you want to go to the effort of creating a Java clone from the
- published specifications that is FRS, and calling it "Mr. Coffee", Sun
- won't stop you.
-
- If Java becomes as popular as everybody expects, it will certainly be
- cloned. (The editor of this HOWTO hereby announces his availablity to
- help write either the Mr. Coffee compiler or the byte-code interpreter
- or both, as soon as suitable specification documents become
- available.)
-
-
- 3.5. Are there any FRS Java Tools?
-
- There is a GNU Emacs mode for editing Java. You can fetch it from
- <ftp://java.sun.com/pub/java/contrib/emacs>.
-
- 3.6. What is Sun's attitude towards FRS Java implementations and
- tools?
-
- Sun people use the term "rogue port" for Java implementations that
- either (a) are performed outside Sun, or (b) don't rely on Sun-
- licensed code (sometimes the term seems to mean one thing, sometimes
- the other). They seem to think some of these already exist, but we
- don't know where they are, nor if they are FRS. They're pretty
- relaxed about the situation.
-
-
- Sun has a Java validation suite. They have said they'll certify any
- Java port that passes it. (Whether this validation will cost money is
- unknown, but Sun says in writing that the suite wil be "publicly
- available" in 1996, which at least hints that it will not.) They're
- prepared to certify rogue ports, though this apparently hasn't
- happened yet.
-
- 4. Java On Linux Questions
-
- Here you can learn the nuts and bolts of getting Java running on your
- Linux.
-
-
- 4.1. Are Java and HotJava included in any of the Linux distributions?
-
- No, not yet, but expect it any week now.
-
- 4.2. How can I get the latest Java distribution for Linux?
-
- Look in <ftp://java.blackdown.org/pub/Java>. The latest Java-for-
- Linux can be downloaded from there. You should browse the
- <ftp://java.blackdown.org/pub/Java/README> first.
-
- The files you'll need are linux.jdk.common.tar.gz and one of either
- linux.jdk.x86-static-motif-bin.tar.gz ot linux.jdk.x86-shared-motif-
- bin.tar.gz, depending on whether you have Motif shared libraries on
- your system.
-
- This port (from the Sun sources by Randy Chapman) is the one that's
- referred to (as the JDK) elsewhere in this HOWTO.
-
- 4.3. What environment will I need to run Java?
-
- For starters, you need an ELF-based Linux. There is no a.out support,
- and at the speed the Linux world is switching over to ELF there is not
- likely to be any in the future.
-
- You need a 1.2.13 or later kernel. Kernels 1.2.12 and older seem to
- have a bug in getcwd(3) that tanks bin/javac because it doesn't check
- the getcwd(3) return code.
-
- You'll need these pieces:
-
-
- o libc.so.5 => /lib/libc.so.5.2.16
-
- o libX11.so.6 => /usr/X11/lib/libX11.so.6.0
-
- o libXt.so.6 => /usr/X11/lib/libXt.so.6.0
-
- o libXext.so.6 => /usr/X11/lib/libXext.so.6.0
-
- o libXpm.so.4 => /usr/X11/lib/libXpm.so.4.3
-
- o libdl.so.1 => /lib/libdl.so.1.7.9
-
- The C and X support libraries may be in your Linux already.
-
- If you don't already have it, get libc.5.2.16.bin.tar.gz from
- <ftp://tsx-11.mit.edu/pub/linux/packages/GCC/>. Uncompress and untar
- and copy the files in the lib subdirectory of the top level of the
- hierarchy to /lib.
-
- If you don't have a current version of ld.so (or libdl.so.1.7.*) you
- will need to update. ld.so.1.7.9 and .11 will work; .10 and other
- early versions will not. Get ld-so.1.7.11.tar.gz from
- <ftp://ftp.ods.com/linux/>; Uncompress and untar it and run
- instldso.sh which is in the top level of the resulting hierarchy.
-
- You can get an Xpm library that will work from
- <ftp://sunsite.unc.edu/pub/Linux/libs/X/libXpm.3.4f-ELF.tar.gz>.
-
- 4.4. Do I need Netscape? Can I use Netscape?
-
- Yes, you need Netscape. HotJava isn't yet available for the beta
- release. Randy Chapman says:
-
- Sun massively changed the awt interface when they shipped
- the beta JDK and have not yet converted HotJava to it. They
- have promised they will, and it should work great with
- linux-jdk when they release it.
-
-
- It's unknown when this will happen.
-
- As of December 1995 only Netscape 2.0b3 is Java-aware. It is
- available at ftp1-7.netscape.com (i.e. at ftp1.netscape.com,
- ftp2.netscape.com,... etc.) The file to get is /2.0b3/unix/netscape-
- v20b3-export.i486-unknown-linux.tar.Z.
-
- Note that Netscape 2.0b3 will run on an a.out system, so it is, in
- theory, possible to write your java app, give it to someone else to
- compile (like maybe the BlackStar Public Compiler
- <http://mars.blackstar.com>), and see the output on your system. If
- you want more than that, get an ELF system.
-
- Adam Smith writes: A tiny amount of fudging (moving one file) is
- required to make Netscape run from the distribution: it will crash
- when loading a page with Java applet(s) if Netsacape's condensed
- single-file version of the *.class files is not first in the CLASSPATH
- environement variable, and I don't know the effect on Java/HotJava of
- having that in the path (since the archived classfile format is
- irregular, I suspect it might work). I have run the Netscape
- successfully on my Slackware 3.0 system.
-
- Steve Greene writes: There's been some discussion on the java-linux
- list on how to configure Java and Netscape to make it pick up your
- local applets for viewing. The consensus seems to be that you need to
- add the path to the applet added to the CLASSPATH environment
- variable, or run a local Webserver and access the applets through the
- local Webserver as if it were over the 'net; you may also need to be
- connected to be able to find java.sun.com (I suspect but do not know
- that this is a holdover from the alpha HotJava browser, and is simply
- to ensure the browser could find the "stock" Sun class libraries on
- there site. I haven't tried any of this yet, so your milage may vary.
-
- 4.5. What mailing lists or newsgroups exist for supporting Java on
- Linux?
-
-
- o java-linux (Maintained by karl@blackdown.org) Discussions and
- developments concerning the port of Java to the Linux operating
- system. Email to java-linux-request@java.blackdown.org with the
- word `subscribe' in the subject to be added to the list.
-
- o java-linux-announce (Maintained by karl@blackdown.org) Moderated
- list for announcements concerning the Java-Linux porting projects.
- Please send e-mail to java-linux-announce-
- request@java.blackdown.org with the word subscribe in the subject,
- to be added to the list.
-
-
- o comp.lang.java Newsgroup for general Java discussion.
-
- o alt.www.hotjava Newsgroup for discussion of the HotJava browser.
-
- 5. Building the Linux Java port on stock Linuxes
-
- In this section, we collect recipes sent to us for building Randy
- Chapman's Java port on various current Linux distributions:
-
-
- 5.1. Slackware distribution ELF kernel 1.2.13.
-
- John Franks <john@math.nwu.edu> writes that he succeeded with the
- following steps:
-
-
- o Get linux-x86.jdk.pre2.static-motif.tar.gz from
- <ftp://www.blackdown.org/pub/Java/linux/> and uncompress it and
- untar it. (The filenames you must fetch have changes for the 1.0
- beta JDK.)
-
- o Get libc.5.2.16.bin.tar.gz from
- ftp://tsx-11.mit.edu/pub/linux/packages/GCC/ Uncompress and untar
- and copy the files in the lib subdirectory of the top level of the
- hierarchy to /lib.
-
- o Get ld-so.1.7.11.tar.gz from ftp://ftp.ods.com/linux/ Uncompress
- and untar it and run "instldso.sh" which is in the top level of the
- resulting hierarchy.
-
- You should now be able to compile and try the "hello world" program
- and applet from Sun following the instructions at
- <http://java.sun.com/progGuide/index.html>.
-
- 5.2. RedHat 2.1/Caldera Preview 2
-
- Steve Greene <sgreene@access.digex.net> reports success doing the
- following steps. I have edited the recipe slightly, so blame any
- mistakes on me. The `JDK' he refers to is the Chapman port of the
- Java Developer's Kit.
-
-
- o From ftp.ods.com, get the rpm available for ld.so.1.7.11. Check
- any RedHat mirror site for:
-
- /pub/mirrors/redhat-2.1/updates/RPMS/ld.so-1.7.11-i386.rpm
-
- I know it is available at ftp.pht.com, ftp.caldera.com. and is
- probably at the other RedHat mirrors as well. Grab it, and do `rpm
- -ivh ld.so-1.7.11-1.i386.rpm' on your system.
-
- o Get the tar file(s) for the statically-linked JDK. Untar it from a
- convenient point. I put mine in /usr/local, so the untar creates
- /usr/local/java/....
-
- o So you can run java as someone other than root (this is a good
- idea!), do `chmod 666 /dev/zero'. Red Hat and Caldera have the
- wrong permissions set on this device out of the box.
-
- o If you haven't already, run ldconfig as root to load the new
- libraries. If you do "ldconfig -v" you can verify you have all
- the libraries loaded. (At least we don't have to build an ELF
- system first!)
-
- o Make sure you're logged in as a user (e.g. non-root). Start X-
- windows, open an X-Term, and try something!
- Steve adds: If I understand the on-line notes correctly, bin/java is a
- script that calls the run-time Java interpreter (used to run Java
- applications), bin/javac is a script for the Java compiler for
- compiling applications and applets, and bin/appletviewer is a script
- that allows you to look at an exisiting (compiled) applet.
-
- A number of demonstration applets are in the demo directory. The
- applet viewer requires a file name.
-
- I haven't figured out the correct syntax to run bin/appletviewer
- directly, but I figured out an alternative by examining the script
- file. To run a demo, I enter this command from the top of my Java
- directory tree, /usr/local/java on my system):
-
- bin/java sun.applet.AppletViewer demo/<directory_name>/exampleN.html
-
- where <directory name> is the subdirectory off demo, and N is the
- number of the example file (some directories have more than 1).
-
- The first time you run Java, a license screen (which reminds me of
- Netscape's) is displayed.
-
- I've started the tutorials available from Sun's java site and the
- similar one put out by the NTMUG. I've discovered some problems with
- the syntax in Sun's tutorial, so I've been following the NYMUG
- tutorial instead for now.
-
- 6. Notes on Known Problems
-
- Steve Greene tells us: These are problems I ran into and how I fixed
- them (e.g., this is my "Been There, Done That" troubleshooting list):
-
- 1. This is my parochial list on thw problems I had; it is not a
- generic troubleshooting list!
-
- 2. It's probably RedHat/Caldera - centric.
-
-
- 6.1. An error message refers to /dev/zero
-
- Go root and do `chmod 666 /dev/zero'.
-
- 6.2. SEGFAULT
-
- Occasionally, you may get a screen full of error messages, and the
- system cheerfully fills up your swap space and locks-up.
-
- You're probably missing a library someplace. Rerun ldconfig -v and
- see what's missing. Perhaps LD_LIBRARY_PATH or CLASS_PATH is not set.
- Finally, some applets are buggy or lock up the Linux JDK.
-
- (BTW, you can stop the lock-up by having another Xterm open with top
- running; use top to kill the java process BEFORE it fills up swap and
- hangs your system!)
-
- Java seems to want lots of resources, so I'd keep the number of
- running/open apps on my desktop to a minimum. It will load on a
- 486DX-2-75 with 8 Mbytes RAM and 16 Mbytes swap (it'll take a minute,
- though). I was able to get two animation applets running
- simultaneously (sort of) before my system ran out of swap space and
- hung.
-
- 6.3. bin/java, bin/javac, or bin/appletviewer gives you a help screen
-
- You left out some command-line parameter.
-
- 6.4. Problem Logging
-
- Finally, Joey Oravec tells us that HotJava keeps a log of what it does
- and any problems in encounters. If you're up to diagnosing something
- yourself, look at $HOME/.hotjava/weblog in the user's home directory.
- That file will make it more obvious if you're perhaps missing a
- library or something.
-
- 7. Related Resources
-
- For general information on Java, there is a FAQ maintained on the
- comp.lang.java newsgroup; it is available at <http://www.city-
- net.com/~krom/java-faq.html>.
-
- There is an older FAQ-style document by Joey Oravec
- joey@sun.science.wayne.edu <mailto:joey@sun.science.wayne.edu> which
- primarily refers to the alpha release. You can find it at
- <http://www.science.wayne.edu/~joey/java/linux.html>. At some point
- these documents may merge.
-
- Here are some Java-related pages:
-
-
- o Karl Asha's General Linux Java Page
- <http://substance.blackdown.org/java-linux.html> LinuxJava Mailing
- List <http://homer.ncm.com/java-linux/> Netrek for Java
- <http://www.cs.utexas.edu/users/hiep/netjav.html> Blue-Skies for
- Java <http://cirrus.sprl.umich.edu/javaweather/>
-
- 8. To Be Added...
-
-
- o More recipes for specific Linux variants.
-
-
- 9. Acknowledgements
-
- Grateful acknowledgement is made to all contributors, including:
-
- o John Franks <john@math.nwu.edu>
-
- o Zachary DeAquila <zachary@zachs.place.org>
-
- o Steve Greene <sgreene@access.digex.net>
-
- o Dave Dittrich <dittrich@cac.washington.edu>
-
- o Dave Flanagan <dave@ora.com>
-
- o Joey Oravec <mailto:joey@sun.science.wayne.edu>
-
- o Adam Smith <aws@cs.brown.edu>
-
- This version incorporates Steve Greene's rumored but never-published
- Red Hat/Caldera mini-HOWTO. I've also swiped some stuff I consider
- useful off Joey Oravec's page -- special thanks to him.
-
- For other HOWTOs and FAQs I maintain, see my home page at
- <http://www.locke.ccil.org/~esr/home.html>.
-